/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://code.google.com/p/dylab/

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

#ifndef __dylab_ComEventListener_h__
#define __dylab_ComEventListener_h__

//===========================================================================================
#include <dylab/simulation/ISimulationComponent.h>
#include <dylab/utils/components/ComponentBase.h>
#include <dylab/simulation/InputEvent.h>
#include <dylab/simulation/HapticsEvent.h>
#include <dylab/simulation/GfxEvent.h>

//===========================================================================================
namespace dylab {

    /** Simulation event listener component type.
	@remarks
		This class defines an interface for the simulation event listener component type.
		Components of this type are responsible for implementing the requested event listener.
    */
    class DYLAB_EXPORT ComEventListener
        : public ISimulationComponent
        , public ComponentBase<ComEventListener>        
    {
	private:
		/// The name under which this listener is stored in the parent simulation.
		String mNameInSimulation;

    public:

        ComEventListener(const String & _componentName);
        virtual ~ComEventListener();

		void setNameInSimulation(const String & _nameInSimulation)
				{ mNameInSimulation = _nameInSimulation; }
		String getNameInSimulation() const
				{ return mNameInSimulation; }

        /** This method is called for the listener, that is registered as input event listener.
		@remarks
			The listener should process the given input event.
		@param[in] _inputEvent
			The input event message with all necessary informations.
        */
        virtual void processEvent(const InputEvent & _inputEvent);

        /** This method is called for the listener, that is registered as haptics event listener.
		@remarks
			The listener should process the given haptics event.
		@param[in] _hapticsEvent
			The haptics event message with all necessary informations.
        */
        virtual void processEvent(const HapticsEvent & _hapticsEvent);

        /** This method is called for the listener, that is registered as graphics event listener.
		@remarks
			The listener should process the given graphics event.
		@param[in] _renderEvent
			The graphics event message with all necessary informations.
        */
        virtual void processEvent(const GfxEvent & _renderEvent);

    protected:

        /** This method is called by the inherated classes in the initialize method.
		@remarks
			Tells the parent simulation that this listener wants to receive 
			events from the input source (keyboard, mouse, etc.).        
        */
        void registerAsInputEventListener();

        /** This method is called by the inherated classes in the initialize method.
		@remarks
			Tells the parent simulation that this listener wants to receive 
			events from the haptics source (haptics device).        
        */
        void registerAsHapticsEventListener();

        /** This method is called by the inherated classes in the initialize method.
		@remarks
			Tells the parent simulation that this listener wants to receive 
			events from the graphics source.         
        */
        void registerAsGfxEventListener();
    };

}

//===========================================================================================
#endif // __dylab_ComEventListener_h__
